package com.guojizhuang.writable;

import org.apache.hadoop.io.Writable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.util.List;
import java.util.ArrayList;

public class MerchantInfoWritable implements Writable {

    private Long user_id;
    private Long merchant_id;
    private Long clicks=0l;
    private Long buys=0l;

    @Override
    public String toString() {
        return user_id +
                "\t" + merchant_id +
                "\t" + clicks +
                "\t" + buys;
    }

    public MerchantInfoWritable(Long user_id, Long merchant_id, Long clicks, Long buys) {
        this.user_id = user_id;
        this.merchant_id = merchant_id;
        this.clicks = clicks;
        this.buys = buys;
    }

    public MerchantInfoWritable() {
    }

    public Long getUser_id() {
        return user_id;
    }

    public void setUser_id(Long user_id) {
        this.user_id = user_id;
    }

    public Long getMerchant_id() {
        return merchant_id;
    }

    public void setMerchant_id(Long merchant_id) {
        this.merchant_id = merchant_id;
    }



    public Long getClicks() {
        return clicks;
    }

    public void setClicks(Long clicks) {
        this.clicks = clicks;
    }

    public Long getBuys() {
        return buys;
    }

    public void setBuys(Long buys) {
        this.buys = buys;
    }

    @Override
    public void write(DataOutput dataOutput) throws IOException {
        dataOutput.writeLong(merchant_id);
        dataOutput.writeLong(user_id);
        dataOutput.writeLong(clicks);
        dataOutput.writeLong(buys);
    }

    @Override
    public void readFields(DataInput dataInput) throws IOException {
        merchant_id=dataInput.readLong();
        user_id=dataInput.readLong();
        clicks=dataInput.readLong();
        buys=dataInput.readLong();
    }
}
